package com.lemon.smartsafetynew.util.common;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;

/**
 * Created by Andrew on 2017/11/10.
 */

public class CheckAppExist {

    private static final String CANON_PRINTER = "jp.co.canon.bsd.ad.pixmaprint";

    public static boolean checkApkExist(Context context, String packageName) {

        if (TextUtils.isEmpty(packageName)) {
            return false;
        }

        try {
            ApplicationInfo info = context.getPackageManager()
                    .getApplicationInfo(packageName,
                            PackageManager.GET_UNINSTALLED_PACKAGES);
            return true;
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }
    }

    public static boolean checkCanonPrinterExist(Context context) {
        return checkApkExist(context, CANON_PRINTER);
    }

}

